# coding: utf-8
# from sqlalchemy import Column, DateTime, Integer, Text
# from flask_sqlalchemy import SQLAlchemy

import time
from application import db


class Kuaidi(db.Model):
    __tablename__ = 'kuaidi'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True, info='编码')
    name = db.Column(db.String, info='收件人名')
    phone = db.Column(db.String, info='收件人手机号码', index=True)
    kuaidi_no = db.Column(db.String, info='快递单号', index=True, unique=True)
    kuaidi_ty = db.Column(db.String, info='快递公司', default="ems")
    kdstatus = db.Column(db.String, info='快递目前状态', nullable=True)
    kdcxshisj = db.Column(db.String, info="快递查询时间", nullable=False)

    def __init__(self, name, phone, kuaidi_no, kuaidi_ty):
        self.name = name
        self.phone = phone
        self.kuaidi_no = kuaidi_no
        self.ctikuaidi_tyme = kuaidi_ty
        self.kdstatus = '{"status":"0","｝'
        self.kdcxshisj = time.time()

    def __repr__(self):
        return "<User {} NO. {}>" .format(self.name, self.kuaidi_no)
